package poketrade.managers;

import java.util.Date;
import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import poketrade.entities.News;

@Stateless
public class NewsManager {
	
	@PersistenceContext(name="Poketrade")
	EntityManager em;
	
	@SuppressWarnings("unchecked")
	public List<News> getNews()
	{
		return em.createNamedQuery("getNews").getResultList();
	}
	
	public void createNews(String title, String content)
	{
		News n = new News();
		n.setTitle(title);
		n.setContent(content);
		n.setPostDate(new Date());
		em.persist(n);
	}
}
